﻿package mortal.game.view.guild.cellrender
{
    import Message.Game.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.common.global.*;
    import mortal.common.tools.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.mvc.core.*;

    public class GuildWareHouseMyApplyListCellRenderer extends GuildCellRenderer
    {
        private var _item:BaseItem;
        private var _txtItemName:GTextFiled;
        private var _txtDate:GTextFiled;
        private var _txtResult:GTextFiled;
        private var _btnCancelApply:GButton;
        private var _line:ScaleBitmap;

        public function GuildWareHouseMyApplyListCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._item = UIFactory.getUICompoment(BaseItem, 2, 5, this);
            this._item.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 3);
            this._txtItemName = UIFactory.textField("", 47, 3, 140, 22, this);
            this._txtDate = UIFactory.textField("", 47, 25, 120, 22, this, GlobalStyle.textFormatLv);
            this._txtResult = UIFactory.textField("" + Language.getString(71113), 193, 15, 66, 22, this);
            this._btnCancelApply = UIFactory.gButton("" + Language.getString(71114), 193, 15, 66, 22, this);
            this._btnCancelApply.configEventListener(MouseEvent.CLICK, this.btnCancelMouseClick);
            this._line = UIFactory.bg(0, 51, 274, 1, this, ImagesConst.SplitLine);
            return;
        }// end function

        private function btnCancelMouseClick(event:MouseEvent) : void
        {
            var _loc_4:Dictionary = null;
            var _loc_2:Object = {};
            var _loc_3:* = this.data as SGuildWarehouseApply;
            _loc_2.uid = _loc_3.uid;
            if (_loc_3.uid == "" || _loc_3 == null)
            {
                _loc_4 = new Dictionary();
                _loc_4[_loc_3.unit] = _loc_3.amount;
                _loc_2.donateMoney = _loc_4;
            }
            else
            {
                _loc_2.donateMoney = new Dictionary();
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.Guild_wareHouse_applyCancel, _loc_2));
            return;
        }// end function

        override public function get data() : Object
        {
            return super.data;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:SGuildWarehouseApply = null;
            super.data = param1;
            if (param1 is SGuildWarehouseApply)
            {
                _loc_2 = param1 as SGuildWarehouseApply;
                this._txtDate.htmlText = HTMLUtil.addColor(DateParser.parse(_loc_2.applyDt, "" + Language.getString(71115)), GlobalStyle.colorLv);
                if (_loc_2.itemCode == 0)
                {
                    this._txtItemName.htmlText = "<p align = \'left\'>" + GameDefConfig.instance.getEPrictNameAddColoer(_loc_2.unit) + "*" + _loc_2.amount + "</p>";
                    this._item.source = GlobalClass.getBitmapData(GameDefConfig.instance.getEPrictUnitBigIcon(_loc_2.unit));
                }
                else
                {
                    this._txtItemName.htmlText = "<p align = \'left\'>" + ItemsUtil.getItemName(new ItemData(_loc_2.itemCode)) + "*" + _loc_2.amount + "</p>";
                    this._item.itemCode = _loc_2.itemCode;
                }
                if (_loc_2.state.value() == EGuildWarehouseState._EGuildWarehouseAgree)
                {
                    this._txtResult.text = "" + Language.getString(71116);
                    this._txtResult.visible = true;
                    this._btnCancelApply.visible = false;
                }
                else if (_loc_2.state.value() == EGuildWarehouseState._EGuildWarehouseRefuse)
                {
                    this._txtResult.text = "" + Language.getString(71117);
                    this._txtResult.visible = true;
                    this._btnCancelApply.visible = false;
                }
                else if (_loc_2.state.value() == EGuildWarehouseState._EGuildWarehouseApply)
                {
                    this._txtResult.visible = false;
                    this._btnCancelApply.visible = true;
                }
            }
            return;
        }// end function

    }
}
